
function [] = test_firwin()

fs = get_sampling_fq();

% a500 sinc

cvs = importdata('..\..\genblep\sinc-a500-pal.csv');
d1 = cvs(:, 1)';
d1 = d1 / trapz(d1);

d6 = firwin('a500', fs, 21000, 2048, false);

figure(1);
hold on;
title('sinc a500');
plot(d1, '.');
plot(d6, 'r');
legend('python-sinc', 'my-sinc');

error_calc(d1, d6);

%

cvs = importdata('..\..\genblep\sinc-a1200-pal.csv');
d1 = cvs(:, 1)';
d1 = d1 / trapz(d1);

d6 = firwin('a1200', fs, 21000, 2048, false);

figure(2);
hold on;
title('sinc a1200');
plot(d1, '.');
plot(d6, 'r');
legend('python-sinc', 'my-sinc');

error_calc(d1, d6);

%

spectrum_cut = 50000;
Fs = 350000;
len = 100;

k1  = fir1(len-1, 2 * spectrum_cut / Fs, kaiser(len, 9));
k1 = k1 / trapz(k1);

k2 = firwin('a1200', Fs, spectrum_cut, len, false);

figure(3);
hold on;
plot(k1, 'g*');
plot(k2, 'r');
legend('matlab-fir1', 'my firwin');
title('firwin test');

error_calc(k1, k2);

end
